import { createRouter, createWebHashHistory } from 'vue-router'
import layout from '@/views/layout/index.vue'
import departmentRouter from './modules/department'
import settingRouter from './modules/setting'
import employeeRouter from './modules/employee'
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/index.vue'),
    hidden: true,
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/NotFound.vue'),
    hidden: true,
  },
  {
    path: '/',
    redirect: '/dashboard',
    component: layout,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index.vue'),
      meta: {
        title: '数据看板',
        icon: 'HomeOutlined'
      }
    }]
  },
  {
    path: '/:pathMatch(.*)*', // vue-router的新通配符
    redirect: '/404',
    hidden: true
  }
]
const asyncRoutes = [
  departmentRouter,
  settingRouter,
  employeeRouter
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: [...routes, ...asyncRoutes]
})

export const resetRouter = () => {
  // router.addRoute(routes)
}
export default router
